home *** CD-ROM | disk | FTP | other *** search
- 10REM>ARCUUDEC
- 20 REM *************************************************************
- 30 REM UUDECODE.BAS
- 40 REM
- 50 REM UUDECODE in Atari Basic
- 60 REM Original version 1.0 23-Sep-1987 by Brian Robinson
- 65 REM This version 2.0 16-Aug-1988
- 70 REM
- 80 REM slow and crude version only designed as a bootstrap
- 90 REM to convert the correct UUDECODE.UUE into UUDECODE.TTP
- 100 REM
- 110 REM Modified for Archimedes - 16 August 1988
- 120 REM by A.F.Abbey - Physics Dept, Leicester University
- 130 REM AFA@UK.AC.LE.STAR
- 140 REM *************************************************************
- 150 MAXCHAR = 127
- 160 CODEDLN = 61
- 170 NORMLEN = 45
- 180 DIM CHTBL(MAXCHAR)
- 190 DEF FNT(A$)=ASC(A$)-32
- 200 FOR C=0 TO MAXCHAR: CHTBL(C)=0: NEXT C
- 210 ON ERROR REPORT:PRINT" at ";ERL:CLOSE #0:END
- 220 REM *************************************************************
- 230 REM main program
- 240 REM *************************************************************
- 250 PRINT
- 260 PRINT "UUDECODE v2.0 16-Aug-1988 AFA"
- 270 PRINT
- 280 INPUT "Enter filename to decode ";INFILE$
- 290 PRINT "File open : ";INFILE$
- 300 ch%=OPENIN(INFILE$)
- 310 PRINT "File opened"
- 320 REPEAT LI$=GET$#ch%:UNTIL LEN(LI$)>0
- 330 REM next 2 lines are a quick and dirty fudge for bad file structure
- 340 REM LI$="table"
- 350 IF LI$="table" THEN GOSUB 490
- 360 IF LEFT$(LI$,5)="begin" THEN GOSUB 710
- 370 GOSUB 850
- 380 LI$=GET$#ch%:IF LEN(LI$)=0 LI$=GET$#ch%
- 390 IF LEFT$(LI$,3)="end" THEN PRINT:PRINT "End of file"
- 400 REPEAT LI$=GET$#ch% :UNTIL LEN(LI$)>0
- 410 IF LEFT$(LI$,4)="size" THEN PRINT:PRINT"Code length ";MID$(LI$,6,(LEN(LI$)-5))
- 420 PRINT
- 430 PRINT "Uudecode complete"
- 440 CLOSE #0
- 450 END
- 460 REM *************************************************************
- 470 REM build a character translation table
- 480 REM *************************************************************
- 490 REM GETTABLE:
- 500 PRINT
- 510 PRINT "Table definition start"
- 520 FOR C=0 TO MAXCHAR: CHTBL(C)=0: NEXT C
- 530 REPEAT LI$=GET$#ch% :UNTIL LEN(LI$)>0
- 540 L=LEN(LI$)
- 550 FOR C=1 TO L
- 560 C$=MID$(LI$,C,1)
- 570 CHTBL(C)=ASC(C$)
- 580 NEXT C
- 590 REPEAT LI$=GET$#ch% :UNTIL LEN(LI$)>0
- 600 L=LEN(LI$)
- 610 FOR C=1 TO L
- 620 C$=MID$(LI$,C,1)
- 630 CHTBL(C+32)=ASC(C$)
- 640 NEXT C
- 650 PRINT "Table definition finish"
- 660 RETURN
- 670 REM *************************************************************
- 680 REM open output file
- 690 REM use a large direct access file to avoid carriage returns
- 700 REM *************************************************************
- 710 REM OPENOUTFILE:
- 720 PRINT
- 730 PRINT LI$
- 740 L=LEN(LI$)-9
- 750 OUTFILE$=MID$(LI$,11,L)
- 760 PRINT "File open : ";OUTFILE$
- 770 ch2%=OPENOUT(OUTFILE$)
- 780 PRINT "File opened"
- 790 RETURN
- 800 REM *************************************************************
- 810 REM decode main data block
- 820 REM all data is decoded as full blocks of 4 characters
- 830 REM to give 3 bytes into the output file
- 840 REM *************************************************************
- 850 REM DECODE:
- 860 lines=0
- 870 PRINT
- 880 REPEAT LI$=GET$#ch% :UNTIL LEN(LI$)>0
- 890 WHILE LEN(LI$)>3
- 900 LL=LEN(LI$)-1
- 910 CL=FNT(LEFT$(LI$,1))
- 920 FOR I%=2 TO LL STEP 4
- 930 G1%=FNT(MID$(LI$,I% ,1))
- 940 G2%=FNT(MID$(LI$,I%+1,1))
- 950 G3%=FNT(MID$(LI$,I%+2,1))
- 960 G4%=FNT(MID$(LI$,I%+3,1))
- 970 B0%=(G1%<<2)+(G2%>>4)
- 980 B1%=((G2%<<4)+(G3%>>2))AND &FF
- 990 B2%=((G3%<<6)+G4%)AND &FF
- 1000 BPUT#ch2%,CHR$(B0%)+CHR$(B1%)+CHR$(B2%);
- 1010 NEXT I%
- 1020 lines=lines+1
- 1030 IF lines MOD 10 =0 PRINT"Lines = ";lines;CHR$(&D);
- 1040 REPEAT LI$=GET$#ch% :UNTIL LEN(LI$)>0
- 1050 ENDWHILE
- 1060 PRINT "Lines decoded = ";lines
- 1070 CL=FNT(LEFT$(LI$,1))
- 1080 IF CL=0 THEN PRINT "End of data block"
- 1090 RETURN
- 1100
-